<?php
$db = JFactory::getDbo();

// get top 5 message
$qr = "SELECT * FROM mere
            WHERE MERE_OCBA_CODE = '".JFactory::getUser()->username."'
                AND MERE_DELF IS NULL
                AND (MERE_CHKF = 0 OR MERE_CHKF IS NULL)
                AND (MERE_FOME_CODE IS NULL OR MERE_FOME_CODE = 0)
            ORDER BY MERE_CODE DESC
            LIMIT 0, 5";
$db->setQuery($qr);
$mess = $db->loadObjectList();


// get count message
$qr = "SELECT count(*) FROM mere
            WHERE MERE_OCBA_CODE = '".JFactory::getUser()->username."'
                AND MERE_DELF IS NULL
                AND (MERE_CHKF = 0 OR MERE_CHKF IS NULL)
                AND (MERE_FOME_CODE IS NULL OR MERE_FOME_CODE = 0)
            ORDER BY MERE_CODE DESC";
$db->setQuery($qr);
$number = $db->loadResult();
?>

<div class="jm-module-content">
    <h3 class="jm-title">メッセージ（<?php echo $number ?> 件）
        <span class="float-right">
            <a href="index.php?top=page&option=com_frmessage&cate=inbox" class="arrow">一覧はこちら</a>
        </span>
    </h3>
    <div class="jm-mod-content">
    <?php foreach($mess as $m){
        echo "<div class='mess'>
            <p><strong>$m->MERE_DATE</strong></p>
            <a href='index.php?top=page&option=com_frmessage&task=view&cate=inbox&cid[]=mese_$m->MERE_CODE'>
                $m->MERE_TITLE
            </a>
        </div>";
    }?>
    <!--<div class="circle-content">
    <p>2013.00.00 &nbsp &nbsp 00:00  &nbsp &nbsp
        <span class="circle"></span>
        <span class="circle"></span>
        <span class="circle"></span>
        <span class="circle"></span>
        さん
    </p>
    <p class="circle-detail"><a href="#">[B&amp;G]
        <span class="circle"></span>
        <span class="circle black"></span>
        <span class="circle"></span>
        <span class="circle black"></span>
        <span class="circle"></span>
        <span class="circle black"></span>
        <span class="circle"></span>
        <span class="circle black"></span>
       の件
        </a>
    </p>
    </div>
    <div class="circle-content">
    <p>2013.00.00 &nbsp &nbsp 00:00  &nbsp &nbsp
        <span class="circle"></span>
        <span class="circle"></span>
        <span class="circle"></span>
        <span class="circle"></span>
        さん
    </p>
    <p class="circle-detail"><a href="#">[B&amp;G]
        <span class="circle"></span>
        <span class="circle black"></span>
        <span class="circle"></span>
        <span class="circle black"></span>
        <span class="circle"></span>
        <span class="circle black"></span>
        <span class="circle"></span>
        <span class="circle black"></span>
        につい
        </a>
    </p>
    </div>
    <div class="circle-content">
    <p>2013.00.00 &nbsp &nbsp 00:00  &nbsp &nbsp
        <span class="circle"></span>
        <span class="circle"></span>
        <span class="circle"></span>
        <span class="circle"></span>
        さん
    </p>
    <p class="circle-detail"><a href="#">[B&amp;G]
        <span class="circle"></span>
        <span class="circle black"></span>
        <span class="circle"></span>
        <span class="circle black"></span>
        <span class="circle"></span>
        <span class="circle black"></span>
        <span class="circle"></span>
        <span class="circle black"></span>
       につい
        </a>
    </p>
    </div>
    <div class="circle-content">
    <p>2013.00.00 &nbsp &nbsp 00:00  &nbsp &nbsp
        <span class="circle"></span>
        <span class="circle"></span>
        <span class="circle"></span>
        <span class="circle"></span>
        さん
    </p>
    <p class="circle-detail"><a href="#">[B&amp;G]
        <span class="circle"></span>
        <span class="circle black"></span>
        <span class="circle"></span>
        <span class="circle black"></span>
        <span class="circle"></span>
        <span class="circle black"></span>
        <span class="circle"></span>
        <span class="circle black"></span>
        <span class="circle"></span>
        <span class="circle black"></span>
        <span class="circle"></span>
        <span class="circle black"></span>
        の件
        </a>
    </p>
    </div>
    <div class="circle-content">
    <p>2013.00.00 &nbsp &nbsp 00:00  &nbsp &nbsp
        <span class="circle"></span>
        <span class="circle"></span>
        <span class="circle"></span>
        <span class="circle"></span>
        さん
    </p>
    <p class="circle-detail"><a href="#">[B&amp;G]
        <span class="circle"></span>
        <span class="circle black"></span>
        <span class="circle"></span>
        <span class="circle black"></span>
        <span class="circle"></span>
        <span class="circle black"></span>
        <span class="circle"></span>
        <span class="circle black"></span>
        <span class="circle"></span>
        <span class="circle black"></span>
        <span class="circle"></span>
        <span class="circle black"></span>
        <span class="circle"></span>
        <span class="circle black"></span>
        <span class="circle"></span>
        <span class="circle black"></span>
        の件
        </a>
    </p>
    </div> -->
    </div>
</div>